﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Xml;
using System.Xml.Serialization;
using System.Runtime.Serialization;


namespace ClientApplication
{
    [Serializable]
    public class ContestPacket
    {
        public bool started { get; set; }

        public List<Judge> judges { get; set; }

        public Judge Admin { get; set; }

        public Contest contest { get; set; }

        public String id { get; set; }

        public System.Guid GUID { get; set; }
        [XmlIgnore]
        public MessageQueue contestMessages { get; set; }

        public ContestPacket(string id)
        {
            started = false;
            judges = new List<Judge>();
            contest = new Contest();
            this.id = id;
            contestMessages = new MessageQueue();
            this.GUID = Guid.NewGuid();
        }
        public ContestPacket()
        {
            started = false;
            judges = new List<Judge>();
            contest = new Contest();
            this.id = "";
            contestMessages = new MessageQueue();
            this.GUID = Guid.NewGuid();
        }
        public ContestPacket(ContestPacket toCopy)
        {
            this.started = toCopy.started;
            this.judges = new List<Judge>(toCopy.judges);
            this.Admin = new Judge(toCopy.Admin);
            this.contest = toCopy.contest;
            this.id = toCopy.id;
            contestMessages = new MessageQueue();
            this.GUID = Guid.NewGuid();
        }
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return false;
            }

            // If parameter cannot be cast to Point return false.
            ContestPacket p = obj as ContestPacket;
            if ((System.Object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (this.GUID == p.GUID);
        }
    }
}
